package net.wds.ssbus.modules.ssbus.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.wds.ssbus.modules.ssbus.mapper.TbSsbusRouteMapper;
import net.wds.ssbus.modules.ssbus.pojo.TbSsbusChannelEntrty;
import net.wds.ssbus.modules.ssbus.pojo.TbSsbusRouteEntrty;
import net.wds.ssbus.modules.ssbus.service.TbSsbusRouteService;
import net.wds.ssbus.modules.sys.controller.AbstractController;
import net.wds.ssbus.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TbSsbusRouteServiceImp extends AbstractController implements TbSsbusRouteService {

    @Autowired
    private TbSsbusRouteMapper tbSsbusRouteMapper;

    @Override
    public IPage<TbSsbusRouteEntrty> list(int pageNo, int pageSize, String key) {
        Page<TbSsbusRouteEntrty> page = new Page(pageNo,pageSize);


        return tbSsbusRouteMapper.list(page,key);
    }

    @Override
    public void update(TbSsbusRouteEntrty tbSsbusRouteEntrty) {
        SysUserEntity u=getUser();
        tbSsbusRouteEntrty.setAddUser(u.getUsername());
        tbSsbusRouteEntrty.setEditTime(new Date());
        tbSsbusRouteMapper.update(tbSsbusRouteEntrty);
    }

    @Override
    public void save(TbSsbusRouteEntrty tbSsbusRouteEntrty) {
        SysUserEntity u=getUser();
        tbSsbusRouteEntrty.setEditUser(u.getUsername());
        tbSsbusRouteEntrty.setAddTime(new Date());
        tbSsbusRouteMapper.save(tbSsbusRouteEntrty);
    }

    @Override
    public TbSsbusRouteEntrty getById(Long id) {
        return tbSsbusRouteMapper.getById(id);
    }

    @Override
    public void removeById(Long id) {
        tbSsbusRouteMapper.delete(id);
    }

    @Override
    public void deletes(Long[] id) {
        tbSsbusRouteMapper.deletes(id);
    }

    @Override
    public List<TbSsbusRouteEntrty> getTbSsbusRouteList() {
        return tbSsbusRouteMapper.getTbSsbusRouteList();
    }
}
